package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsNarratorDetail;
import com.macro.mall.dto.BmsNarratorParam;
import com.macro.mall.model.BmsNarrator;
import com.macro.mall.portal.service.BmsNarratorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@Api(tags = "BmsNarratorController")
@Tag(name = "BmsNarratorController", description = "讲解项目")
@RequestMapping("/narratorProject")
public class BmsNarratorController {

    @Autowired
    private BmsNarratorService bmsNarratorService;

    @ApiOperation("分页查询讲解项目")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsNarrator>> getList(@RequestBody BmsNarratorParam bmsNarratorParam) {
        List<BmsNarrator> bmsNarratorList = bmsNarratorService.getList(bmsNarratorParam);
        return CommonResult.success(CommonPage.restPage(bmsNarratorList));
    }

    @ApiOperation("根据id获取讲解项目信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorDetail> getItem(@PathVariable Long id) {
        BmsNarratorDetail bmsNarratorDetail = bmsNarratorService.getItem(id);
        return CommonResult.success(bmsNarratorDetail);
    }

    @ApiOperation("根据场馆信息获取讲解项目信息")
    @RequestMapping(value = "/getProjectByMuseumId/{museumId}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorDetail> getDefaultProject(@PathVariable Long museumId) {
        BmsNarratorDetail bmsNarratorDetail = bmsNarratorService.getProjectByMuseumId(museumId);
        return CommonResult.success(bmsNarratorDetail);
    }

    @ApiOperation("获取默认讲解项目信息")
    @RequestMapping(value = "/getDefaultProject", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorDetail> getDefaultProject() {
        BmsNarratorDetail bmsNarratorDetail = bmsNarratorService.getDefaultProject();
        return CommonResult.success(bmsNarratorDetail);
    }

}
